Contents
 Surface Help Contents

Introduction

File Options(reading data, printing...)

Grid Generation

View Options(2d Contour maps, 3d Surfaces...)

Copying to the clipboard

Edit Options (Title, Contour lines, view angles, grid dimensions, technical parameters...)

Zooming

Future Enhancements Planned

Changes since the previous version

Author

Copyright

Copying and Redistribution Conditions

Registration

Disclaimer

Algorithm


File... Options
File Options (reading, saving, printing... )

Reading Scattered Data

Loading Test Data

Saving the grid to a file

Loading a grid from a file

Generating a DXF data file

Printing


View... Options
View Options (2d contours, 3d surfaces...)

Viewing a Contour Map

Viewing a perspective representation of the  Surface

Contour Map and Perspective View options

Displaying Grid Coordinate and Contour information

Zooming in or Magnifying the display


Edit... Options

Editing the Title

Editing the number or value of the contour lines

Editing the viewpoint for the perspective view of the surface

Editing the grid coordinates and dimensions

Editing Technical Parameters


Introduction

This program will read in a set of scattered data points which represent a surface and will generate a grid which represents the surface defined by these points. The gridded surface may be viewed as a contour map or as a perspective view of the gridded surface, optionally with hidden lines removed. The left mouse button may be used to zoom in on the gird. The right mouse button may be used to display information about the generated grid coordinates, data coordinates and contour line values.

The above represents the output from a rather trivial set of 9 data points. An 80 by 80 grid representing 1000 scattered data points will typically be gridded in 10 to 20 seconds on a 33Mhz 486. An 125 by 125 grid (the maximum allowed) representing 15,000 data points will be gridded in less than a minute on the same machine. The program makes no special demands on the PC it runs on and will run on much smaller machines at a (much) slower speed. The display may be copied to the clipboard, printed or output as a DXF data file for input into Autocad or other programs that support that format.

SURFACE is a lean program. It will run on very modest hardware platforms. It is well suited for situations where it is desired to have a quick look at a set of data points, for example under field conditions where only a portable PC is available.


Reading Scattered Data
Reading Scattered Data Points

The options File..., Input metric data points... or File..., Input NOS data points... will allow you to read a file containing the scattered data points defining the surface.

The Scattered Data points are typically organized three points to a line in order, the x coordinate, the y coordinate and the z coordinate for each point. The points should be separated by blanks. The program is not sensitive to line boundaries however. For example you could have two x,y,z triplets on each line.


Loading Metric Data
.Metric Data Points are points defined in the normal decimal, base 10 number system. The following is a sample set of metric data points:

31.55667	-97.13333	-38.2
31.67167	-97.10000	-37.6
31.80333	-97.10000	-39.9
31.97167	-97.00500	-33.4
- etc. -
31.97000	-97.12167	-40.3
31.98500	-97.12667	-40.1
31.99833	-97.13167	-40.1
31.50000	-97.34667	-58.4


Loading NOS(Latitude/Longtitude) Data
.NOS Data Points are data points expressed in latitude and longitude using the format dddmmssss where ddd is the degrees, mm is the minutes and ssss is the seconds.  The following is a sample set of NOS data points:

56450769 153301646 -46
56450422 153302280 -47
56450132 153303003 -48
56450859 153305357 -51
-etc. -
56451148 153300923 -45
56451474 153300211 -44
56451852 153302732 -44
56451634 153303348 -44


Loading Test Data

The option File, Load Test Data will load a small set of 9 data points.


Saving a grid to a file
Saving the grid to a file

The option File, Save grid to a file will output the current grid to a file as a plain text file. This grid may later be used as input to Surface using File, Load grid from file.


Loading a grid from a file

The option File, Load grid from file will load a grid previously saved with File, Save the grid to a file or a grid provided by yourself that is in the correct format.


Format of a grid saved to a file
Format of a grid in a file

The following is the format that will be used by File, Save grid to a file. It is also the format you must use in order to input gridded data to Surface from some other source using File, Load grid from file.

The first line of the file contains three numbers, the number of grid lines in the x direction,  the number of grid lines in the y direction and optionally an offset to be applied to the z values in the grid.  Undefined z coordinates are flagged by a negative number so all valid z values must be positive. The offset is subtracted from the z values for the grid data to yield the true value at any given position. Surface outputs all floating point numbers using scientific notation. For grids provided from other sources scientific notation need not be used for input. Grids generated from NOS formatted data points have grid coordinates represented by degrees and fractions of a degree.

The following lines in the file will contain, in order:

1.	The values of the coordinates of the x grid lines.

2.	The values of the coordinates of the y grid lines.

3. 	The values for the z values for the grid. These numbers are output with the y coordinate varying fastest. Undefined intersections are indicated by a z value of -99999.

Except for the first line Surface is not sensitive to line breaks so the data after the first line may be spread across as many lines as desired, but must be supplied in the given order. For example.


Example of the format of a grid saved to a file

The following is the file created as a result of using File, Save the grid to a file for a five by five grid generated from the internal test data.

5 5 0e+00
1e+00 3.25e+00 5.5e+00 7.75e+00 1e+01
1e+00 3.25e+00 5.5e+00 7.75e+00 1e+01
1e+00 3.527506e+00 2e+00 2.175612e+00 -9.9999e+04 2.61706e+00 7e+00 3.45895e+00 3.312072e+00 4e+00
2.144419e+00 3.600058e+00 3.149526e+00 4.524836e+00 4.626828e+00 -9.9999e+04 2.397182e+00 3.000304e+00 9e+00 5.930425e+00
-9.9999e+04 2.295494e+00 3.398936e+00 4.832572e+00 3e+00

The third number (z offset) on the first line is optional, and if missing defaults to zero. Except for the first line Surface is not sensitive to the ends of lines. The data following the first line may be split across as many lines as desired but must be supplied in the correct order.


Output the grid in DXF format
Output the display as DXF data

The option File, Generate a DXF file will optionally write the grid, scattered data points and contour lines to a file in the Autocad DXF format. This file may then be used as input to Autocad or other programs that support this format. The grid data is written out using the DXF LINE primitive on layer GRID. The scattered data points are output as POINT primitives on layer SCATDATA.  The contour lines are output using the LINE primitive. All contours of a given value are put out in a single layer with the name "CONTOURnnnnn", where 'nnnnn' represents the contour line value. Periods and + are changed to underscores for compatibiliby with layer naming conventions. Similarly - is changed to 'm'. Scientific notation may be used. For example the contour lines for the  1.5 contour would be put in the layer named "CONTOUR1_5". The lines for the 18.92326 contours would be put in the layer named "CONTOUR1_892326e_01".

All data is output using full x,y,z representation with no rotation applied. NOS data is output as degrees and fractions of a degree.

Whatever is displayed will be output to the file. For example if you don't want the grid information click on View..., ... with hidden surface grid so the grid is no longer displayed. If you don't want the contour lines display the data in 3d mode.

WARNING: DXF files can become extremely large - especially for larger grids.


Grid Generation

By default grid generation occurs automatically whenever necessary. The options File... Generate grid now and File... ...generate grid automatically allow you to take manual control of grid generation.

Grid Generation can take some time - depending mostly on the size of the grid being generated. A dialog box is displayed which shows the progress of the grid generation.


Grid Generation Dialog Box

The grid generation dialog box provides you with information about the generation of the grid as it proceeds. The Status: is either "Presorting Data Points", which is done to increase the efficiency of the grid generation, or "Generating...". See the Algorithm for more information.

Average Scan Bandwidth:  This value shows the average number of data points that are being examined in order to evaluate a grid intersection.  This statistic is most heavily impacted by the Technical Parameters items Scan bandwidth cutoff  and Distance cutoff.   Average Search Shell  In order to evaluate a grid intersection this program shells outwards from the grid intersection looking for scattered data points. This item displays the average number of shells examined around each grid intersection.
Clicking on the Cancel button will cancel grid generation. The portion of the grid generated up until it was canceled will be displayed.


Printing

Selecting File, Print... will print the current display.


Viewing a Contour Map

The option View..., 2d Contours displays this picture. This view always displays contour lines - regardless of the setting of the View, Contour Lines option.


Viewing a Perspective Representation of the Surface

The option View..., 3d Surface will display the surface as a grid from the perspective point of a viewer 35 degrees above the surface with the surface rotated by 35 degrees around the z axis. The perspective projection is set up to show a surface for a viewpoint at a distance approximately 5 times the length of the x axis. These options may be changed with the Edit..., Angle menu.

If the options to display contour lines or data points is chosen in conjunction with the hidden surface option contour lines and data points are not hidden.


Contour Map and Perspective View options.
Contour Map and Perspective View options

The options under the View... menu control what will be displayed in both the 2d Contours or 3d Surface displays, with the exception that contours are always displayed in the 2d Contours view.

The Black and white display option will mainly be useful to people using portable computers with an LCD display panel, or who are printing to non color printers. Such devices typically map colors into some level of grey tone. Choosing this option may improve the quality of the display or print.


Copying to the Clipboard

Choosing Edit..., Copy to clipboard will copy the current display to the clipboard. The image is deposited in the clipboard as a metafile.


Editing the Title

Choosing Edit..., Title... will allow you to change the title for the display. By default the title is set to the name of the file the scattered data points or grid came from.


Changing the number of contour lines lines
Editing the number of contour lines

The program will contour the surface with 10 contour lines spread over the range of values defined by the surface. The number of lines plotted may be changed with the Edit..., Contour Intervals dialog box. In this dialog box you may either change the number of contours and let the program choose the starting value and increment for the contours, or you may explicitly specify the starting value, increment and end contour value. In the latter case do not change the value for the number of contours, the program will re-calculate that automatically. (If you change the number of contours value the program will assume you would like it to determine the starting value and increment).

By default every 5th contour line will be highlighted by making it dashed. Which lines are highlighted may be changed in this dialog box. Setting it to 1 will highlight every line. Setting it to 100 will result in no lines being highlight.


Editing the viewpoint for the perspective view of the surface

The viewpoint for the perspective view of the surface can be changed with the Edit..., Angle menu. The option Above specifies the angle of the viewpoint above the surface. About specifies how much the surface is to be rotated about the z axis. Perspective Projection specifies a number that represents the distance the viewpoint is from the surface expressed as multiples of the length of the x axis.


Editing the Grid Dimensions
Editing the grid line data

The option Edit..., Grid Line Data may be used to change the size of the grid and the value for the grid coordinates for the x and y axes. For each axis you may either specify the number of grid lines and let the program choose a starting value, increment and end value for the grid coordinates, or you may specify the starting value, increment and end value for the grid coordinates. In the latter case do not change the value for the number of grid lines. Surface will do that automatically (If you change the number of grid lines Surface assumes you would like it to recalculate thestarting value, increment and end value.)

When the data is initially loaded Surface will select a grid size that will contain approximately 5 times as many grid intersections as there are grid points. The minimum grid size defaults to 10 by 10. (This multiplier may be changed - see Technical Parameters).


Technical Parameters

The Edit..., Technical Parameters option allows you to change some of the internal assumptions used by the program. These are:

Automatic grid size ratio

Scan bandwidth cutoff

Distance cutoff

Surface Z-Ratio

Edge Sensitivity


Automatic grid size ratio

This parameter defines how many grid intersections the grid should contain relative to the number of scattered data points. A parameter of 8 specifies that the grid should have approximately 8 times as many grid intersections as there are scattered data points. The dimensions of the grid are defined initially as sqrt(n*ratio) where n is the number of scattered data points and ratio is the value of this option. See also Edit..., Grid Line Data.

This value may be changed with the Edit..., Technical Parameters option. It does not take effect until the next data set is read in.


Scan bandwidth cutoff

In order to evaluate a grid intersection the program scans outwards from the grid intersection examining scattered data points. The number of points examined impacts heavily on the performance of the program. The Scan bandwidth cutoff number along with the Distance Cutoff number tells the program when to stop looking. When any new points will not contributed more than 1/(scan bandwidth cutoff) towards the value of a grid intersection scanning will cease in that direction.

This value may be changed with the Edit..., Technical Parameters option.


Distance cutoff

Some grid intersections are so isolated from any data points they should not be evaluated. The Distance cutoff specifies a number that allows the program to flag a grid intersection as unevaluated. It is also used along with the Scan bandwidth cutoff  to limit the number of scattered data points examined during the evaluation of a grid intersection. The Distance cutoff specifies a percent of the Density Distance. If no points are found within this distance the grid intersection is flagged as being unevaluated.

If the data points tend to be clustered in small groups the area between the clusters will tend to not be contoured or displayed as a 3d surface. To contour these areas between clusters increase the value of this parameter. A value of 300 will normally be sufficient to fill in most areas. Higher values will affect the speed of the grid generation adversely. Note the Average Scan Bandwidth statistic during grid generation time. If this statistic is higher than 15 the Distance cutoff is probably set needlessly high.

This value may be changed with the Edit..., Technical Parameters option.


Perspective Surface Z - Ratio

Typically the units used for the x and y axis are quite different from the units used for the z axis. For example x and y may specify latitude and longitude and z specify magnetometer measurements. For a perspective view of the surface it is often not practical to use the raw unscaled data as the resulting surface may look too flat to show relief detail or too "mountainous". The z-ration figure specifies that the z axis range should be scaled to be n% of the range of the x-axis. This parameter defaults to 60%.

If the z-ratio is set to zero the z axis will not be scaled.

This value may be changed with the Edit..., Technical Parameters option.


Edge Sensitivity

In some cases grid intersections near the edges of the grid should not be contoured. This parameter specifies a percentage of the Density Distance. If the closest point to a grid intersection is farther away than this distance, the program examines the number of consecutive empty octants around the grid intersection. If there are 4 or more consecutive empty octants the grid intersection is not evaluated.

This value may be changed with the Edit..., Technical Parameters option.


Zooming

Click anywhere with the left mouse button on the display of a 2d contour map or 3d surface to magnify that particular part of the picture. Zoom..., unzoom will restore the picture to it's original size. Zoom..., Freeze zoom level will defeat further zooming. In this state clicking anywhere on the display will move the point under the cursor towards the middle of the display but not change the size of the picture. This allows you to "pan" about the map. Clicking on Zoom..., Freeze zoom again will enable zooming again. Previous zoom will back up to the previous picture. Zoom..., Negative zoom will result in the display shrinking when the cursor is clicked anywhere in the display. Clicking on it again will resume normal magnification.


Grid Coordinate and Data Point Information

Click anywhere with the right mouse button on the display of a 2d contour map or 3d surface to display a dialog box that shows the x, y and z data and the closest contour value for the nearest grid coordinate or data point. This data will be displayed in a dialog box that may be canceled when it is no longer needed. This function is not enabled if a 3d hidden grid is being displayed. Choose the transparent grid option instead.

Use caution when interpreting the value of the closest contour line!

The contour line is the one closest to the selected data point or grid coordinate not the mouse position. The contour line is the nearest in the "z" direction only. The shape of the surface and how it is being viewed may make the contour line not appear visually closest on the display. The indicated contour line may not be visible at all if the grid coordinate or data point is at the top of a hill or bottom of a valley.


Future Enhancements Planned

I currently have requests for the following enhancements:

Allow an option to overlay an arbitrary shaped polygon on the surface.

Export the grid in DXF format as 3d faces or polygon mesh.

Eliminate unnecessary redrawing of the display.

Hide contour lines and data points in the 3d hidden surface view.

Remove the limit on the number of scattered data points.

Add xyz axis and labels in the plot.

Allow customized unevenly distributed contour lines.

Allow the input of data in Surveyors DCA format which includes optional note data about each point. Save this information and display it when right mouse button information is requested.

Please e-mail suggestions  and priorities to the author.


Changes from the previous version

The following changes have been made since the release of the Dec. 23/94 version:

The grid coordinate values may be specified.

Grid coordinate and data point information can be displayed by clicking the right mouse button near the grid intersection or data point of interest.

Undefined grid coordinates are not displayed in 2D contour display mode.

Help buttons have been added to many of the dialog boxes.

The menus have been changed, I hope to a cleaner more intuitive format. Keyboard accelerators are supported.

Grid generation can be put under manual control (as opposed to automatic).

The display can be saved in DXF format using LINE and POINT primitives.

The display may be viewed without the use of colors (black lines only).

Please e-mail suggestions and priorities to the author.


Author

John Coulthard

3135 West 11th

Vancouver, B.C.

CANADA    V6K 2M8

E-mail: w.j.coulthard@ubc.ca


Copyright (c) 1993 by W. John Coulthard
Copyright  1993 - 1995 John Coulthard
          All Rights Reserved


Copying and Redistribution Conditions

Surface Version 2 is available using anonymous FTP from

- SimTel in the file ...win3/gis/surface2.zip

- ftp.ucs.ubc.ca in the file /pub/msdos/ubc/surface2.zip

This file is unregistered shareware and may be freely distributed. For less than 100 data points the shareware version has the same functionality as the registered version. For more than 100 points many functions are disabled (for example printing, copying the display to the clipboard, modifying contour values, etc.). See Registration for information about purchasing a registered copy.

The author would appreciate knowing who is using the program and hearing any comments about it.


Registraion
Registration

Surface Version 2 is Shareware. To purchase a registered copy send a bank draft or money order in the amount of $50.00 Canadian or equivalent in US funds to the author. Please specify a registration name that will appear in the About box of the program. Please contact the author for information about pricing for site licenses or for educational purposes. Please read the Disclaimer before ordering.

The registered version will not display the initial dialog box announcing that the program is unregistered. The word "unregistered" will not appear as part of the program title nor in any part of the output it produces. The program has full functionality for more than 100 data points. The registered version grants the right to use the software on one computer or workstation at any given time.


Disclaimer

Persons who are unfamiliar with machine contouring and grid generation techniques may find articles in the June issue of Geobyte interesting. A quote from the conclusion of the article "Contouring: Art or Science?" by Daniel J. Tearpock, p 43, reads "...contour maps are interpretations - they are not absolutely correct. "

DISCLAIMER OF WARRANTY

THIS SOFTWARE IS SOLD "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OR MERCHANTABILITY. THE SELLER'S SALESPERSONS MAY HAVE MADE STATEMENTS ABOUT THIS SOFTWARE. ANY SUCH STATEMENTS DO NOT CONSTITUTE WARRANTIES AND SHALL NOT BE RELIED ON BY THE BUYER IN DECIDING WHETHER TO PURCHASE THIS PROGRAM.

THIS PROGRAM IS SOLD WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES WHATSOEVER. BECAUSE OF DIVERSITY OF CONDITIONS AND HARDWARE UNDER WHICH THIS PROGRAM MAY BE USED, NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER IS ADVISED TO TEST THE PROGRAM THOROUGHLY BEFORE RELYING ON IT. THE USER MUST ASSUME THE ENTIRE RISK OF USING THE PROGRAM. ANY LIABILITY OF SELLER OR MANUFACTURER WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF THE PURCHASE PRICE.


Algorithm

Grid generation:

Each grid intersection is divided into octants. The closest data point in each octant is found. The intersection is set to the average of these points weighted by 1/(distance from grid intersection)**2.
Any given grid intersection may be flagged as unevaluated. This may happen because there are no data points nearby (controlled by the Distance Cutoff parameter), or because the grid intersections are on the edge of a region (controlled by the Edge Sensitivity parameter).

Contouring:

The grid squares are triangulated by taking the midpoint of each grid as the average of the four corners. This yields only one way a contour line can traverse the grid square. Linear interpolation is used to determine the contour crossings.

Hidden Surface Drawing:

The hidden surface is rendered by drawing the grid squares from the back to the front (as viewed) using polygon fill. Currently contour lines and data points are not hidden. Hidden contour lines may be added in the future.


Metafile Definition

A metafile is a representation of a picture that consists of descriptions of the individual elements that make up the picture( the lines, rectangles, text and so forth). With an appropriate drawing package, for example Microsoft Draw that comes with Word for Windows, it is possible to edit (scale, delete, move...) each individual element in the image. The individual elements are the grid lines, each contour line, the title and so forth. Packages like Microsoft Paint will automatically convert the metafile to a bit map.


Density Distance Definition

The Density Distance can be thought of as approximately the average distance between points if the points were evenly distributed throughout the grid. It is the diameter of a circle that has an area equal to the total area of the grid divided by the total number of scattered data points.


Unevaluated Intersections

Unevaluated intersections will not be contoured, nor will they be displayed as part of the gridded surface.